package cn.tedu.spring.example;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 测试类: xml方式配置Bean
 */
public class TestUserXml {
    public static void main(String[] args) {
        /*
            1.创建 IoC 容器;
            2.获取 Bean 对象;
            3.使用 Bean 对象;
            ClassPathXmlApplicationContext: 基于xml文件方式构建IoC容器;
            AnnotationConfigApplicationContext: 基于注解方式构建IoC容器;
         */
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        UserXml userXml = (UserXml) context.getBean("userXml");
        userXml.run();
    }
}





